import Vue from 'vue'
import VueRouter from 'vue-router'
import home from '../views/doc/index.vue'
// 路由
import lowcode from './lowcode.js'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: home,
    meta: {
      title: '链股低代码平台示例'
    }
  },
  lowcode
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
})

// 设置浏览器导航栏标题
router.afterEach((to) => {
  setTimeout(() => {
    window.document.title = to.meta.title || window.document.title
  }, 0)
})

// 获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
// 修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default router
